package homework;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Lottery implements Runnable{
    private static final  int [] arr ={10,5,20,50,100,200,500,800,2,80,300,700};
    private static  final List<Integer>pool;
    static {
        pool = new ArrayList<>();
        for (int i : arr) {
            pool.add(i);
        }
    }
    @Override
    public void run() {
        Random r = new Random();
        Thread thread = Thread.currentThread();
        while (true){
            synchronized (this) {
                if(pool.isEmpty())break;
                try {
                    Thread.sleep(300);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                int i = r.nextInt(pool.size());
                Integer prize = pool.remove(i);
                System.out.println(thread.getName()+prize);
            }
        }
    }
}
